<template>
	<code-note-page name="kmpNote" :dialogGoUri="dialogGoUri" v-bind:code="code" :infos="infos"/>
</template>

<script>
import infos from '~/data/kmp.json'
import infosWithC from '~/data/kmpWithC.json'
import store from '~/utils/store'

export default {
	props: {
		c: {
			type: Boolean,
			default: false
		}
	},
	created() {
		store.setItem('c', this.c)
	},
	data() {
		return {
			code : `int KMP(char *s, char *t, int *next) 
{
	int i = 0, j = 0;

	while (i < strlen(s) && j < strlen(t))
	{
		if (j == -1 || s[i] == t[j]) 
		{
			i++;
			j++;
		}
		else 
			j = next[j];
	}

	if (j == strlen(t))
	   return i - j;
	else 
	   return -1;
 }`,
			infos: this.c ? infosWithC : infos,
			dialogGoUri: '/kmpVisualizer'
		}
	}
};
</script>

<style>
</style>
